//CHECKSTYLE:OFF

package com.ractoc.opengamefinder.api.translators;

import java.util.Map;
import java.util.LinkedHashMap;
/**
 * Main translator class. Only has one method, translate.
 * @author Mark Schrijver
 * @version 1.0
 */
public final class TranslatorMap {

    private static Map <String, Translator> translatorsByKey = new LinkedHashMap <String, Translator>();

    static {
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.LoginMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateLoginMessageToLoginNetworkMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.network.LoginNetworkMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateLoginNetworkMessageToLoginMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.results.LoginMessageResult",
                        new com.ractoc.opengamefinder.api.translators.TranslateLoginMessageResultToLoginResultNetworkMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.results.network.LoginResultNetworkMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateLoginResultNetworkMessageToLoginMessageResult());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.RegisterMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateRegisterMessageToRegisterNetworkMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.network.RegisterNetworkMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateRegisterNetworkMessageToRegisterMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.ChatLineMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatLineMessageToChatLineNetworkMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.network.ChatLineNetworkMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatLineNetworkMessageToChatLineMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.ChatCreateRoomMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatCreateRoomMessageToChatCreateRoomNetworkMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.network.ChatCreateRoomNetworkMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatCreateRoomNetworkMessageToChatCreateRoomMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.results.ChatCreateRoomMessageResult",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatCreateRoomMessageResultToChatCreateRoomNetworkMessageResult());
        translatorsByKey.put("com.ractoc.opengamefinder.api.results.network.ChatCreateRoomNetworkMessageResult",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatCreateRoomNetworkMessageResultToChatCreateRoomMessageResult());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.ChatEnterRoomMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatEnterRoomMessageToChatEnterRoomNetworkMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.network.ChatEnterRoomNetworkMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatEnterRoomNetworkMessageToChatEnterRoomMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.results.ChatEnterRoomMessageResult",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatEnterRoomMessageResultToChatEnterRoomNetworkMessageResult());
        translatorsByKey.put("com.ractoc.opengamefinder.api.results.network.ChatEnterRoomNetworkMessageResult",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatEnterRoomNetworkMessageResultToChatEnterRoomMessageResult());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.ChatLeaveRoomMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatLeaveRoomMessageToChatLeaveRoomNetworkMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.network.ChatLeaveRoomNetworkMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatLeaveRoomNetworkMessageToChatLeaveRoomMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.results.ChatLeaveRoomMessageResult",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatLeaveRoomMessageResultToChatLeaveRoomNetworkMessageResult());
        translatorsByKey.put("com.ractoc.opengamefinder.api.results.network.ChatLeaveRoomNetworkMessageResult",
                        new com.ractoc.opengamefinder.api.translators.TranslateChatLeaveRoomNetworkMessageResultToChatLeaveRoomMessageResult());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.GetAvatarMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateGetAvatarMessageToGetAvatarNetworkMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.messages.network.GetAvatarNetworkMessage",
                        new com.ractoc.opengamefinder.api.translators.TranslateGetAvatarNetworkMessageToGetAvatarMessage());
        translatorsByKey.put("com.ractoc.opengamefinder.api.results.GetAvatarMessageResult",
                        new com.ractoc.opengamefinder.api.translators.TranslateGetAvatarMessageResultToGetAvatarNetworkMessageResult());
        translatorsByKey.put("com.ractoc.opengamefinder.api.results.network.GetAvatarNetworkMessageResult",
                        new com.ractoc.opengamefinder.api.translators.TranslateGetAvatarNetworkMessageResultToGetAvatarMessageResult());
    }

    /**
     * Constructor.
     */
    private TranslatorMap() {
    }

    /**
     * Selects the correct translator and uses that translator to translate the supplied message.
     * Only one translator is possible per bean class.
     * If no translator is available null is returned.
     * @param beanToTranslate the bean that needs to be translated.
     * @return the translated bean or null if no translator was available.
     */
    public static Object translate(final Object beanToTranslate) {
        Object result = null;
        if (beanToTranslate != null) {
            final Translator translator = translatorsByKey.get(beanToTranslate.getClass().getName());
            if (translator != null) {
                result = translator.translate(beanToTranslate);
            }
        }
        return result;
    }
}

//CHECKSTYLE:ONFF

